package com.dynamo.transport.network.practise.bio;

import java.io.IOException;

/**
 * @author duanyimiao
 * @create 2018-10-27 9:54 PM
 * @description
 **/
public class MainTest {

    public static void main(String[] args) throws Exception {
        new Thread(new Runnable() {
            @Override
            public void run() {
                //启动server
                Server server = new Server("127.0.0.1", 8888);
                server.channelHandler(new PrintHandler());
                try {
                    server.start();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }).start();

        Thread.sleep(1000);
        for(int i = 0;i<10;i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        //启动客户端连接
                        Client client = new Client("127.0.0.1", 8888);
                        client.startConnect();

                        client.write("ni hao1 dffffffffffffffvvvvbbdfsfsfsfdsfsdfsd\n对方的负担发呆发呆发呆发呆发呆发呆发呆发呆发呆发呆发\n");
                        client.write("ni hao2\n");
                        client.read();

                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }).start();
        }
    }

}
